﻿	<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/static/include/top.jsp"%>
<script>document.title="企业列表";</script>
<script type="text/javascript">
function openEditWin(id){
	openWin("修改详情","${baseURL}/unit/edit?id="+id,800,500,xxx);
}
function openViewWin(id){
	openWin("查看详情","${baseURL}/unit/view?id="+id,800,500);
}

function openAddWin(){
	openWin("增加","${baseURL}/role/createUnit",800,500,xxx);
}
function openReportTypeEditWin(id){
	openWin("关联报表信息","${baseURL}/unit/reportTypeEdit/"+id,550,550);
}
function xxx(){
	searchForm.submit();
}
function impUnitInfo(){
	
	if ($("#uploadFile").val()==""){
		layer.alert("请选择导入的模板文件。");
		return ;		
	}
	
	uploadForm.submit();
	
	
}
</script>

<table>
	<tbody>

		<tr>
			<th><img src="${ctx}/static/images/pages/cen/rig/ico_01.png"
				align="absmiddle">&nbsp;单位管理</th>
		</tr>
		<tr class="tab_grey">
			<td>
				<form name="searchForm" action="" method="post">
					<input type="hidden" name="p" value="1" /> 录入年份：
					 <select id="createYear" name="createYear" class="tab_textbut">
						<option value="">请选择..</option>
						<c:forEach var="year" items="${yearList}">
							<option value="${year}">${year}</option>
						</c:forEach>
					</select> <span class="tab_text"> 单位名称： </span> <input id="unitName"
						type="text" name="unitName" value="${param['unitName']}" size="20"
						class="tab_textbut" /> 
						<span class="tab_text">单位类型：</span>
					<select id="roleId" name="roleId" class="tab_textbut">
						<option value="">请选择..</option>
						<c:forEach var="role" items="${roleList}">
							<option value="${role.id}">${role.roleName}</option>
						</c:forEach>
					</select> 
					<a class="tab_but" href="#"
						onclick="searchForm.action='${baseURL}/role/unitList';searchForm.submit();return false;">查询</a>
					<a class="tab_but" href="#" onclick="clearInput();return false;">清空</a>
					<a class="tab_but" href="#"
						onclick="openAddWin()">增加</a>
					<a class="tab_but" href="#" onclick="delByIds('${ctx}')">批量删除</a>
				</form>
				<form name="uploadForm" target="upload"
					action="${baseURL}/unit/import" method="post"
					enctype="multipart/form-data">
					<a class="tab_but02" href="${baseURL}/role/downloadUnitTemple"	onclick="${baseURL}/role/downloadUnitTemple">下载单位模板</a>
					<input type="file" name="uploadFile" id="uploadFile"> <a
						class="tab_but02" href="#"
						onclick="impUnitInfo();return false;">单位信息导入</a>${msg }
				</form>

				
				<script>
		$("#roleId").val("${param['roleId']}");
		$("#createYear").val("${param['createYear']}");
		$("#unitName").val("${param['unitName']}");
		$("#unitNo").val("${param['unitNo']}");
		$("#year").val("${param['year']}");
		$("#typeId").val("${param['typeId']}");
		
		
		function clearInput() {
			$("#roleId").val("");
			$("#createYear").val("");
			$("#unitName").val("");
			$("#unitNo").val("");
		}
		</script> <iframe name="upload" width="0" height="0" frameborder="0"></iframe>
			</td>
		</tr>

	</tbody>
</table>



<br />
<c:if test="${empty obj.operationResult}">
	<b>没有符合条件的记录。</b>
</c:if>
<c:if test="${not empty obj.operationResult}">

	<table id="listTable">
	<tbody>
		<tr>
		<th width="3%"><input type="checkbox" onclick="selectAll(this.checked);"></th>
				<th width="8%">录入年份</th>
				<th width="20%">企业名称</th>
				<th width="10%">企业编号</th>
				<th width="10%">行政区划</th>
				<th width="10%">单位类型</th>
				<th width="10%">单位法人</th>
				<th width="10%">联系电话</th>
				<th>操作</th>
				
			
		</tr>
		<c:forEach var="oneRow" items="${obj.operationResult}">

			<tr>
				<td><input name="chk"
					type="checkbox" id="chk" value="${oneRow.id}" /></td>
				<td align="left" >${oneRow.createYear}</td>
				<td align="left" class="tab_td_rig">${oneRow.unitName}</td>
				<td align="left" >${oneRow.superCompanyCode}</td>
				<td align="left" >${oneRow.areaName}</td>
				<td align="left" >${oneRow.roleName}</td>
				<td align="left" >${oneRow.fr}</td>
				<td align="left" >${oneRow.tel}</td>
				<td align="left" ><a href="#"
					onclick="openEditWin('${oneRow.id}')"><img
						src="${baseURL}/static/images/tab/ico_01.png" width="16"
						height="16" border="0" align="absmiddle" />修改</a> <a href="#"
					onclick="openViewWin('${oneRow.id}')"><img
						src="${baseURL}/static/images/tab/ico_01.png" width="16"
						height="16" border="0" align="absmiddle" />查看</a>
					<a href="#"	onclick="openReportTypeEditWin('${oneRow.id}')"><img
						src="${baseURL}/static/images/tab/ico_01.png" width="16"
						height="16" border="0" align="absmiddle" />关联报表</a></td>
			</tr>
		</c:forEach>
		<tr class="tab_grey">
				<td colspan="9" align="center" valign="middle" class="tab_white">
				<div class="pagination"> 
					<%@ include file="../include/listpage2.jsp"%>
				</div>
				<div class="clear"></div>
				</td>
			</tr>	
		
		</tbody>
	</table>
	<script>

function selectAll(checkAllFlag) {
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		checkArray[i].checked = checkAllFlag;
	}
}

function getRep(ptype) {
	
	var myDate = new Date();
	pyear=myDate.getFullYear(); 
	alert(pyear);
	$.getJSON("${baseURL}/unit/getReps?year="+pyear+"&typeId="+ptype, function(data) {
		$("#reportTypeId").empty();
		$("#reportTypeId").append( "<option value='0'>请选择..</option>" );
		
	 	$.each(data, function(i, item) {
            $("#reportTypeId").append( "<option value='" + item.id + "'>" + item.typeName + "</option>" );
        });
 });
}

function delByIds(prefix){
	
	var str="";
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		if(checkArray[i].checked){
			str += checkArray[i].value + ",";
		}
	}
	var dot = str.lastIndexOf(",");
	if(dot==-1){
		layer.alert("请选择要删除的单位。");
		return;
	}else{
		str = str.substring(0,dot);
	}
	
	layer.confirm("确认删除？", function(){
		var url=prefix+"/role/deleteMany";
		$.post(url,{"idStr":str,},function(data){
			layer.msg("删除成功", 1, 1);
			searchForm.submit();
		},'json');
		
	});	

}
</script>
</c:if>

<%@ include file="/static/include/bottom.jsp"%>
